package com.koron.css2.serviceManage.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.mapper.BankInterfaceConfigMapper;
import com.koron.css2.serviceManage.vo.BankInterfaceConfigVO;
import com.koron.util.Constant;
import com.koron.util.DBSourceUtils;
import net.sf.json.JSONObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

public class BankInterfaceConfigList implements ServerInterface{
	
	
	private static Logger logger = LogManager.getLogger(BankInterfaceConfigList.class);

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		
		@SuppressWarnings("rawtypes")
		MessageBean<List> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", List.class);
		try {			
			JSONObject pa=JSONObject.fromObject(req.getData());
			String companyNo=pa.getString("companyNo");
			BankInterfaceConfigMapper mapper = factory.getMapper(BankInterfaceConfigMapper.class,DBSourceUtils.getDbEnv(companyNo));
			List<BankInterfaceConfigVO> list = mapper.selectBankInterfaceConfigList();
			info.setData(list);
		} catch (Exception e) {
			info.setCode(Constant.MESSAGE_INT_FAIL);
			info.setDescription(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return info;
	}

}
